package com.bm.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor

/*
 * 订单修改
 */
public class OrderModification {
    private String orderId;//订单id
    private List<Item> addedItems;//添加商品
    private List<Item> removedItems;//移除商品
    private Map<String, Integer> updatedItems;//商品数量
    private double originalTotalPrice;//原始总价
    private double newTotalPrice;//新的价格
    private double discountChange;//折扣更改
    private LocalDateTime modificationTime;//订单更改时间

    public OrderModification(String orderId) {
        this.orderId = orderId;
        this.addedItems = new ArrayList<>();
        this.removedItems = new ArrayList<>();
        this.updatedItems = new HashMap<>();
    }
    public void addUpdatedItem(String itemId, int newQuantity) {
        this.updatedItems.put(itemId, newQuantity);
    }

    @Override
    public String toString() {
        return "OrderModification{" +
                "orderId='" + orderId + '\'' +
                ", addedItems=" + addedItems +
                ", removedItems=" + removedItems +
                ", updatedItems=" + updatedItems +
                ", originalTotalPrice=" + originalTotalPrice +
                ", newTotalPrice=" + newTotalPrice +
                ", discountChange=" + discountChange +
                ", modificationTime=" + modificationTime +
                '}';
    }
}
